public class ThreadDemo11 {
    public static void main(String[] args) throws InterruptedException {
//        MyThread4 myThread4 = new MyThread4();
//        myThread4.start();
//
//        Thread.sleep(3000);
//        myThread4.interrupt();// 唤醒线程，本质让这个sleep方法抛出异常


        MyThread5 myThread5 = new MyThread5();
        myThread5.start();

        Thread.sleep(3000);
        myThread5.stop();// 过时了

    }
}

class MyThread4 extends Thread {
    @Override
    public void run() {
        try {
            Thread.sleep(365 * 24 * 3600 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("新年快乐");

    }
}


class MyThread5 extends Thread {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("新年快乐");
        }


    }
}
